package com.jiangruan.javaproject;

import com.jiangruan.javaproject.Bigjob.AggreGation;
import com.jiangruan.javaproject.Bigjob.RpcBitcoin;
import com.jiangruan.javaproject.address.Address;
import com.jiangruan.javaproject.address.VerifyAddress;
import com.jiangruan.javaproject.service.*;

import java.security.KeyPair;
import java.util.Scanner;

/**
 * @author:xulonghua
 * @email:3162193565@qq.com
 * desc:
 * datetime 2021/12/7 9:25
 */
public class Main {
    public static void main(String[] args) {
        System.out.println ("Hello World");
        Main main = new Main();
        main.menu();
    }

    public void menu(){
        while (true){
            System.out.println ("========期末作业========");
            System.out.println ("本系统支持的功能：");
            System.out.println ("1.查看聚合数据API");
            System.out.println ("2.Rpc实现比特币客户端通信");
            System.out.println ("3.生成比特币地址和校验");
            System.out.println ("0.退出");
            Scanner scanner = new Scanner ( System.in );
            int next =scanner.nextInt ();
            if (next==0){
                break;
            }
            switch (next){
                case 1:
                    AggreGation aggregation = new AggreGation ();
                    aggregation.aggregation ();
                    break;
                case 2:
                    RpcBitcoin rpcBitcoin = new RpcBitcoin ();
                    rpcBitcoin.rpcbitcoin ();
                    break;
                case 3:
                    Address address = new Address ();
                    KeyPair keyPair = address.generateKey ();
                    String adress = address.newAddress ( keyPair );
                    System.out.println (adress);
                    VerifyAddress verifyAddress = new VerifyAddress ();
                    boolean b = verifyAddress.CheckAddress ( adress );
                    System.out.println (b);
                    break;
                default:
                        System.out.println ("请输入正确的编号");
            }
        }

    }
}
